﻿function postcomment2(cid, aid, mid) {
    alert(cid); 
   
   }



   function postcomment(cid, aid, mid) {

       var x = document.getElementById("comment").value;
       if (mid != -1)
           x = document.getElementById("commentfor" + mid).value;

       if (x.length > 0) {
           var xmlhttp;

           if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
               xmlhttp = new XMLHttpRequest();
           }
           else {// code for IE6, IE5
               xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
           }
           xmlhttp.onreadystatechange = function () {
               if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                   if (mid == -1) {
                       document.getElementById("comment").value = "";
                       
                       loadtopic(cid);
                       
                   }
                   else {
                       document.getElementById("commentfor" + mid).value = "";
                       hidecomment(mid);
                       showcomment(mid);
                   }
               }
           }
           xmlhttp.open("GET", "Postcomment.aspx?cid=" + cid + "&aid=" + aid + "&mid=" + mid + "&text=" + x, true);
           //xmlhttp.open("GET", "Login.aspx?tk=" + tk + "&mk=" + mk + "&type=" + 1, true);
           xmlhttp.send();

       }
   }




function search2() {
    var ask = document.getElementById("tbsearch").value;


    window.location = "searchresult.aspx";
}

function search(type) {
    //document.getElementById("content-center").innerHTML = document.getElementById("tbsearch").value;
    var ask = document.getElementById("tbsearch").value;
    var xmlhttp;

    if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp = new XMLHttpRequest();
    }
    else {// code for IE6, IE5
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange = function () {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            document.getElementById("content-center").innerHTML = xmlhttp.responseText;
        }
    }

    xmlhttp.open("GET", "Searchmaps2.aspx?ask=" + ask, true);
    xmlhttp.send();
}


//start facebook comment

function loadtopic(cid) {

    
    var xmlhttp;

    if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp = new XMLHttpRequest();
    }
    else {// code for IE6, IE5
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange = function () {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            document.getElementById("messages").innerHTML = xmlhttp.responseText;
            
        }
    }

    xmlhttp.open("GET", "Loadtopic.aspx?cid=" + cid, true);
    xmlhttp.send();
}







function hidecomment(type) {
    document.getElementById("maincomment" + type + "").innerHTML = "<div id='maincomment" + type + "' class='messageinner' style='color:Gray; '> <a href='#'> Like</a>&nbsp;  <a href='#' onclick='showcomment(" + type + ")'> Show comment</a> &nbsp; <a href='#'> Share</a> &nbsp;&nbsp; December 24 at 11:13pm </div>";
    document.getElementById("subcomment" + type + "").innerHTML = "";
}


function showcomment(type) {

    //alert(type);
    //document.getElementById("maincomment" +type + "").innerHTML = "<div id='maincomment" +type + "' class='messageinner' style='color:Gray; '> <a href='#'> Like</a>&nbsp;  <a href='#' onclick='hidecomment(" + type + ")'> Hide comment</a> &nbsp; <a href='#'> Share</a> &nbsp;&nbsp; December 24 at 11:13pm </div>";
    //document.getElementById("subcomment" + type + "").innerHTML = "<div class='messageinner' id='subcomment" + type + "'> <div class='fbsubcontent'><div class='fbsubstorycontent'><div class='fbsubprofileimg'><a href='#'>    <img src='images/profile1.jpg' width='45px'  /></a> </div><div class='submessageinner'> <a href='#'>Tienle Nguyen</a> Tin hot nóng hổi đây: Rượu cần chính gốc Tây a a a Nguyên, giá 110k/1 bình 2.5lit, và 140k/ 1 bình 4 lít. Mua số lượng nhiều thì có giảm giá.Mọi chi tiết xin vui lòng liên hệ sđt:0937.686.526 nhé!!!Mong mọi người ủng hộ!!!! hihiP/S: giao hàng tận nơi ( nếu ở xa thì cho mình xin thêm ít phí) hihi</div><div class='submessageinner' style='color:Gray; '> December 24 at 11:13pm &nbsp;&nbsp; <a href='#' style='font-weight:normal'>Like</a></div></div></div><div class='fbsubcontent'><div class='fbsubstorycontent'><div class='fbsubprofileimg'><a href='#'>    <img src='images/profile1.jpg' width='45px'  /></a> </div><div class='submessageinner'> <a href='#'>Tienle Nguyen</a> Tin hot nóng hổi đây: Rượu cần chính gốc Tây Nguyên, giá 110k/1 bình 2.5lit, và 140k/ 1 bình 4 lít. Mua số lượng nhiều thì có giảm giá.Mọi chi tiết xin vui lòng liên hệ sđt:0937.686.526 nhé!!!Mong mọi người ủng hộ!!!! hihiP/S: giao hàng tận nơi ( nếu ở xa thì cho mình xin thêm ít phí) hihi</div><div class='submessageinner' style='color:Gray; '> December 24 at 11:13pm &nbsp;&nbsp; <a href='#' style='font-weight:normal'>Like</a></div></div></div><div class='fbsubcontent'><div class='fbsubstorycontent'> <input type='text' name='comment' id='tb_comment' style='color:Gray; font-size:13px; width:440px;' value=' Write a comment...' onclick='dosomething(3)'/><input type='button' name='Subcom' value='Comment' style='font-size:13px'/></div></div></div>    ";


    var xmlhttp;

    if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp = new XMLHttpRequest();
    }
    else {// code for IE6, IE5
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange = function () {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            document.getElementById("maincomment" + type + "").innerHTML = "<div id='maincomment" + type + "' class='messageinner' style='color:Gray; '> <a href='#'> Like</a>&nbsp;  <a href='#' onclick='hidecomment(" + type + ")'> Hide comment</a> &nbsp; <a href='#'> Share</a> &nbsp;&nbsp; December 24 at 11:13pm </div>";
            document.getElementById("subcomment" + type + "").innerHTML = xmlhttp.responseText;
        }
    }
    xmlhttp.open("GET", "Loadcomment.aspx?mainid=" + type, true);
    xmlhttp.send();
}


function viewcost(type) {

    alert("Chức năng chưa code :D");

}


function fee_learnmore(type) {
    if (type == 1) {
        document.getElementById("learnmore").innerHTML = "<p>Private: khóa học này chỉ người tạo mới thấy<br/ > Public (recomment): khóa học cho phép người khác nhìn thấy và tham gia học</p>";
        document.getElementById("quantity1").innerHTML = "<a href=#' onclick='fee_learnmore(2)'> Hide</a>";
    }

    if (type == 2) {
        document.getElementById("learnmore").innerHTML = "";
        document.getElementById("quantity1").innerHTML = "<a href=#' onclick='fee_learnmore(1)'> Learn more</a>";

    }

    if (type == 3) {
        document.getElementById("learnmore").innerHTML = "<p>Available now: Các học viên trong lớp học phải làm bài tập này, ngược lại hiện giờ các học viên không nhìn thấy bài tập này</p>";
        document.getElementById("quantity1").innerHTML = "<a href=#' onclick='fee_learnmore(4)'> Hide</a>";
    }

    if (type == 4) {
        document.getElementById("learnmore").innerHTML = "";
        document.getElementById("quantity1").innerHTML = "<a href=#' onclick='fee_learnmore(3)'> Learn more</a>";

    }
}


function dosomething(type) {
    if (type == 1) {
        alert("Chức năng chưa code :D");
    }

    if (type == 2) {
        document.getElementById("sidebar").innerHTML = "";
    }

    if (type == 3) {
        document.getElementById("tb_comment").value = "";
    }

}

function hidetextbox(id) {

    var textid = "commentfor" + id;
    document.getElementById(textid).value = "";
}


function login() {

    var tk = document.getElementById("txt_account").value;
    var mk = document.getElementById("txt_pass").value;



    var xmlhttp;

    if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp = new XMLHttpRequest();
    }
    else {// code for IE6, IE5
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xmlhttp.onreadystatechange = function () {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200 && xmlhttp.responseText == "1") {
            document.getElementById("userinfo").innerHTML = tk;
        }
    }
    xmlhttp.open("GET", "Login.aspx?tk=" + tk + "&mk=" + mk + "&type=" + 1, true);
    xmlhttp.send();
}


//end facebook comment 
